<?php
# ============================================================================
# 版权所有 Chilcoo.com，并保留所有权利。
# 网站地址: http://www.chilcoo.com/ccerp
# ----------------------------------------------------------------------------
# 这不是一个自由软件！你不能通过任何方式破解本软件.
# 使用:不允许对程序代码以任何形式任何目的的再发布。
# ============================================================================
# $Author: Chilcoo Inc. *
# $Official website  : www.chilcoo.com
# 
# 文件信息:
# File : /cs2/ws/jp/zip/default.php
# 订单综合处理页面，包含回调的AJAX命令集

# 提示除去 E_NOTICE 之外的所有错误信息 

error_reporting(E_ALL&~E_NOTICE);
# 引用common.inc.php
require_once (dirname(__FILE__).'/../../../include/common.inc.php');
# 头文件格式指定
header('Content-type:application/json;charset=utf-8');


class cws_jp_zip{
	var $token = '';
	var $zip = '';
	function __construct(){
		# 验证是否是POST访问
		if($_SERVER['REQUEST_METHOD'] == "POST"){
			$this->token = $_POST['token'];
			$this->zip = $_POST['zip'];
		}
		# 验证是否是GET访问
		else{
			$this->token = $_GET['token'];
			$this->zip = $_GET['zip'];
		}

	}
	function render(){
		# 邮政编码查询
		$zipcode = array('ref'=>'error.');
		if($this->token == config::TOKEN_GET_ZIPCODE){
			$ws = 'http://chilcoo.com/CWS/jp/open/WebServiceJp.asmx?WSDL';
			$client = new SoapClient($ws); 
			$params = array('zip'=>$this->zip);
			$zipcode = $client->ZipCode($params);
		}
		echo json_encode($zipcode>);
	}
}

$jp_zip = new cws_jp_zip();
$jp_zip->render();
?>

